package com.example.mybatisdemo1.controller;

import com.example.mybatisdemo1.entity.User;
import com.example.mybatisdemo1.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;


@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/login")
    public boolean login(String username, String password) {
        System.out.println(username + password);
        User userInfo = userService.queryUserByPassword(username, password);
        if (userInfo != null) {
            return true;
        }
        return false;
    }


    @RequestMapping("/getuserById")
    public User getUserById(Integer id) {
        return userService.getUserById(id);
    }

    @RequestMapping("getall")
    public List<User> getAll(String type) {
        return userService.getAllUser(type);
    }


}

